package jpa.demo;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class HibernateDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			Session session = HibernateUtil.getSession();
			Transaction ts = session.beginTransaction();
			System.out.println("开始建立数据");		
			for (int i = 0; i < 10; i++) {
			    Company company = new Company();
			    company.name = "企业 第"+i+"号";
			    company.description="第"+i+"号的说明";
			    session.save(company);
			}
			ts.commit();
			session.close();
			System.out.println("完成！");
		} catch (HibernateException e) {
			e.printStackTrace();
		}
  

	}

}
